package com.daihou.BCJ.others;

import com.daihou.config.TheAuth;
import com.daihou.model.ceres.In_Others;
import com.daihou.utils.ConfigOthers;
import com.daihou.utils.DHHttpUtil;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class otDuductUpdate {
	private String url;
	Map<String, String> headers;
	@BeforeTest(description = "测试准备工作,获取Authorization对象")
	public void beforeTest() throws IOException {
		url= ConfigOthers.getUrl(In_Others.DEDUCTUPDATE.toString());
		headers=new HashMap<>();
		//设置请求头中的Authorization
		headers.put("Authorization", TheAuth.getAuth());
		//需要admin权限
		headers.put("X-UserName", "admin");
	}

	@Test(description = "更新批量划扣任务")
	public void s1() throws IOException {
		String strBody = "{\"id\":51,\"name\":\"zidong\",\"partner\":\"RRD\",\"startOverdueDays\":500,\"endOverdueDays\":502,\"frequency\":\"EveryDay\",\"startTime\":\"06:05:00\",\"startDate\":null,\"endDate\":null,\"isInfinite\":0,\"monthDay\":0,\"status\":\"Stopped\"}";
		String result = DHHttpUtil.post_with_String(url,strBody,headers).toJSONString();
		System.out.println("================ "+result);
		Assert.assertTrue(result.contains("\"message\":\"操作成功\",\"status\":\"0\""));
	}
}